import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 请假记录信息 */
export interface ReportLeave {
  id: number // 编号
  processInstanceId: string // 实例ID
  userId: number // 教师ID
  userName: string // 姓名
  deptId: number // 部门ID
  deptName: string // 部门
  leaveStartTime: string | Dayjs // 请假开始时间
  leaveEndTime: string | Dayjs // 请假结束时间
  leaveDays: number // 请假天数
  remark: string // 请假说明
  sort?: number // 排序
  status?: number // 状态
}

// 请假记录 API
export const ReportLeaveApi = {
  // 查询请假记录分页
  getReportLeavePage: async (params: any) => {
    return await request.get({ url: `/school/report-leave/page`, params })
  },

  // 查询请假记录详情
  getReportLeave: async (id: number) => {
    return await request.get({ url: `/school/report-leave/get?id=` + id })
  },

  // 新增请假记录
  createReportLeave: async (data: ReportLeave) => {
    return await request.post({ url: `/school/report-leave/create`, data })
  },

  // 修改请假记录
  updateReportLeave: async (data: ReportLeave) => {
    return await request.put({ url: `/school/report-leave/update`, data })
  },

  // 删除请假记录
  deleteReportLeave: async (id: number) => {
    return await request.delete({ url: `/school/report-leave/delete?id=` + id })
  },

  /** 批量删除请假记录 */
  deleteReportLeaveList: async (ids: number[]) => {
    return await request.delete({ url: `/school/report-leave/delete-list?ids=${ids.join(',')}` })
  },

  // 导出请假记录 Excel
  exportReportLeave: async (params) => {
    return await request.download({ url: `/school/report-leave/export-excel`, params })
  }
}
